test "左侧填充" {
  if left_pad("a", 5, "b") != "bbbba" {
    fail("left_pad a with b to length 5 failed")
  }
  if left_pad("abc", 5, "d") != "ddabc" {
    fail("left_pad abc with d to length 5 failed")
  }
  if left_pad("abcde", 5, "f") != "abcde" {
    fail("left_pad abcde with f to length 5 failed")
  }
  if left_pad("a", 5, "bc") != "bcbc".substring(start=0, end=4) + "a" {
     fail("left_pad a with bc to length 5 failed")
  }
}

test "右侧填充" {
  if right_pad("a", 5, "b") != "abbbb" {
    fail("right_pad a with b to length 5 failed")
  }
  if right_pad("abc", 5, "d") != "abcdd" {
    fail("right_pad abc with d to length 5 failed")
  }
  if right_pad("abcde", 5, "f") != "abcde" {
    fail("right_pad abcde with f to length 5 failed")
  }
  if right_pad("a", 5, "bc") != "a" + "bcbc".substring(start=0, end=4) {
     fail("right_pad a with bc to length 5 failed")
  }
}

test "两侧填充" {
  if left_and_right_pad("a", 5, "b") != "bba" + "bb" {
    fail("left_and_right_pad a with b to length 5 failed")
  }
  if left_and_right_pad("abc", 5, "d") != "dabc" + "d" {
    fail("left_and_right_pad abc with d to length 5 failed")
  }
  if left_and_right_pad("abcde", 5, "f") != "abcde" {
    fail("left_and_right_pad abcde with f to length 5 failed")
  }
  if left_and_right_pad("a", 5, "bc") != "bc" + "a" + "bc" {
     fail("left_and_right_pad a with bc to length 5 failed")
  }
}

test "repeat" {
  if repeat("a", 3) != "aaa" {
    fail("repeat a 3 times failed")
  }
  if repeat("ab", 2) != "abab" {
    fail("repeat ab 2 times failed")
  }
} 
